# -*- coding: utf-8 -*-
"""
-------------------------------------------------
Project Name: luffcity_study_code
File Name: test1.py
Author: kij13
Create Date: 2021/3/7
-------------------------------------------------
"""
# class Kij(object):
#     age = 0
#     def __init__(self,name):
#         self.name = name
"""

class A:
    def __init__(self):
        pass

    def func1(self):
        print("func1",self)

    @classmethod
    def func2(cls):
        print("func2",cls)

    @staticmethod
    def func3(self):
        print("func3", self)

a=A()

a.func1()  #func1 <__main__.A object at 0x00000000041A52E8>
A.func1(a) #func1 <__main__.A object at 0x00000000041A52E8>   #类调用绑定到对象的方法需要传第一个参数

A.func2()  #func2 <class '__main__.A'>
a.func2()  #func2 <class '__main__.A'>  #对象调用绑定到类的方法不需要传第一个参数

a.func3(a) #func3 <__main__.A object at 0x00000000041A52E8>
A.func3(a) #func3 <__main__.A object at 0x00000000041A52E8>

a.func3(A) #func3 <class '__main__.A'>
A.func3(A) #func3 <class '__main__.A'>


class Base(object):
    def __init__(self,name):
        self.name = name
        self.testfunc()
    def testfunc(self):
        print ('do Base Testfunc')
class Son(Base):
    pass
    # def testfunc(self):
    #     print ('do Son Testfunc')

sonobj = Son('sonobj')





class Base(object):
    def testfunc(self):
        print ('do Base Testfunc')
class Son(Base):
    def __init__(self,name):
        self.name = name
        self.testfunc()
    def testfunc(self):
        print ('do Son Testfunc')
class Base2(object):
    def testfunc(self):
        print ('do Base2 Testfunc')
class GrandSon(Base2,Son):
    pass

sonobj = GrandSon('sonobj')





class A:
    def func(self):
        super().func()
        print('AAA')
class B:
    def func(self):
        print('BBB')

class C(A,B):
    pass
c=C()
print(C.mro())
c.func()

"""

class List99:
    def __init__(self,x):
        self.seq=list(x)

    def append(self,value):
        if not isinstance(value,str):
            raise TypeError('must be str')
        self.seq.append(value)

    @property
    def mid(self):
        index=len(self.seq)//2
        return self.seq[index]
    def __getattr__(self, item):
        print(item,type(item),123456)
        return getattr(self.seq,item)

    def __str__(self):
        return str(self.seq)

    def __call__(self, *args, **kwargs):
        print('__call__')
        return self

# l=List99((1,2,3))

import time
time.sleep(0.02)

class Fun():
    def __init__(self):
        pass
    def run(self,a,b):
        print('run',a,b)

    def __call__(self, *args, **kwargs):
        # def inner(a,b):
        #     print(a,b)
        # return inner
        return self.run







# l.append('1')
#
# print(l.mid)
# l.insert(0,123123123123123123123123123)
# # print(l.seq)
# print(l.__class__,type(l))
#
# import sys
# print(sys.modules[__name__])




# class List(list): #继承list所有的属性，也可以派生出自己新的，比如append和mid
#     def append(self, p_object):
#         ' 派生自己的append：加上类型检查'
#         if not isinstance(p_object,int):
#             raise TypeError('must be int')
#         super().append(p_object)
#
#     @property
#     def mid(self):
#         '新增自己的属性'
#         index=len(self)//2
#         return self[index]
#
# l=List([1,2,3,4])
# print(l)
# l.append(5)
# print(l)
# # l.append('1111111') #报错，必须为int类型
#
# print(l.mid)
#
# #其余的方法都继承list的
# l.insert(0,-123)
# print(l)
# l.clear()
# print(l)













